//
//  Type_2CViewCell.m
//  Travel_M_Travel
//
//  Created by Sun on 15/3/23.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "Type_2CViewCell.h"
#import "AboutDataData.h"
#import "AboutElemData.h"
#import "HFCollectionRView.h"
#import "UIImageView+WebCache.h"
#import "UIColor+AddColor.h"
@implementation Type_2CViewCell

- (void)dealloc
{
    [_imageView release];
    [_nameLabel release];
    [_dateLabel release];
    [_cycleLabel release];
    [_viewConunt release];
    [_local release];
//    [_userName release];
//    [_userPhoto release];
    [_aboutData2 release];
    [super dealloc];
}


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        
        
        self.imageView = [[UIImageView alloc] init];
       // 加圆角
        _imageView.clipsToBounds = YES;
        _imageView.layer.cornerRadius = 5;
        [self addSubview:_imageView];
        [_imageView release];
        
        self.nameLabel = [[UILabel alloc] init];
        _nameLabel.textColor = [UIColor colorFromHexCode:@"#121a2a"];
        _nameLabel.font = [UIFont boldSystemFontOfSize:15];
        _nameLabel.adjustsFontSizeToFitWidth = YES;
        [_imageView addSubview:_nameLabel];
        [_nameLabel release];
        
//        UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(105, 25, 20, 15)];
//        lable.text = @"天";
//        lable.font = [UIFont boldSystemFontOfSize:12];
//        lable.textColor = [UIColor colorFromHexCode:@"181d4b"];
//        [self.imageView addSubview:lable];
//        [lable release];

        
        self.dateLabel = [[UILabel alloc] init];
        _dateLabel.textColor = [UIColor colorFromHexCode:@"#121a2a"];
        _dateLabel.font = [UIFont boldSystemFontOfSize:12];
        [_imageView addSubview:_dateLabel];
        [_dateLabel release];
        
        self.cycleLabel = [[UILabel alloc] init];
        _cycleLabel.font = [UIFont boldSystemFontOfSize:12];
        _cycleLabel.textColor = [UIColor colorFromHexCode:@"#121a2a"];
        [_imageView addSubview:_cycleLabel];
        [_cycleLabel release];
        
        self.viewConunt = [[UILabel alloc] init];
        _viewConunt.font = [UIFont boldSystemFontOfSize:12];
        _viewConunt.textColor = [UIColor colorFromHexCode:@"#121a2a"];
        [_imageView addSubview:_viewConunt];
        [_viewConunt release];
        
//        UILabel *labelL = [[UILabel alloc] initWithFrame:CGRectMake(160, 25, 100, 15)];
//        labelL.text = @"次浏览";
//        labelL.font = [UIFont boldSystemFontOfSize:12];
//        labelL.textColor = [UIColor colorFromHexCode:@"181d4b"];
//        [self.imageView addSubview:labelL];
//        [labelL release];
        
        self.local = [[UILabel alloc] init];
        _local.font = [UIFont boldSystemFontOfSize:12];
        _local.textColor = [UIColor colorFromHexCode:@"#121a2a"];
        [_imageView addSubview:_local];
        [_local release];
        
//        self.userName = [[UILabel alloc] init];
////        _userName.backgroundColor = [UIColor whiteColor];
//        _userName.textColor = [UIColor colorFromHexCode:@"181d4b"];
//        _userName.font = [UIFont boldSystemFontOfSize: 11];
//        _userName.adjustsFontSizeToFitWidth = YES;
//        _userName.textAlignment = NSTextAlignmentCenter;
//        [_imageView addSubview:_userName];
//        [_userName release];
//        
//        self.userPhoto = [[UIImageView alloc] init];
//        _userPhoto.backgroundColor = [UIColor brownColor];
//        _userPhoto.clipsToBounds = YES;
//        _userPhoto.layer.cornerRadius = 15;
//        [_imageView addSubview:_userPhoto];
//        [_userPhoto release];
        

    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    _imageView.frame = CGRectMake(0, 0, 290, 160);
    _nameLabel.frame = CGRectMake(10, 5, 270, 20);
    _dateLabel.frame = CGRectMake(10, 25, 70, 15);
    _cycleLabel.frame = CGRectMake(90, 25, 50, 15);
    _viewConunt.frame = CGRectMake(130, 25, 200, 15);
    _local.frame = CGRectMake(10, 40, 290, 15);
//    _userPhoto.frame = CGRectMake(240, 105, 30, 30);
//    _userName.frame = CGRectMake(200, 135, 90, 15);
}

- (void)setAboutData2:(AboutDataData *)aboutData2
{
    if (_aboutData2 != aboutData2) {
        [_aboutData2 release];
        _aboutData2 = [aboutData2 retain];
    }
    NSString *str = self.aboutData2.cover_image_w640;
    str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *url = [NSURL URLWithString:str];
    [_imageView setImageWithURL:url];
    
    _nameLabel.text = self.aboutData2.name;
    _dateLabel.text = self.aboutData2.first_day;
    NSString *strDay = [[NSString stringWithFormat:@"%@", self.aboutData2.day_count] stringByAppendingString:@"天"];
    _cycleLabel.text = strDay;
    NSString *strView = [[NSString stringWithFormat:@"%@", self.aboutData2.view_count] stringByAppendingString:@"次浏览"];
    _viewConunt.text = strView;
    _local.text = self.aboutData2.popular_place_str;
//    _userName.text = [self.aboutData2.user objectForKey:@"name"];
    
//    NSString *strU = [self.aboutData2.user objectForKey:@"avatar_m"];
//    strU = [strU stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//    NSURL *urlU = [NSURL URLWithString:strU];
//    [_userPhoto setImageWithURL:urlU];
    
    
    NSLog(@"%@", self.aboutData2.view_count);

    NSLog(@"应该是 图片的信息%@", str);
}



@end
